from pydantic import BaseModel, Field
from typing import Optional

from decimal import Decimal
from datetime import datetime
from datetime import date


class ProjectResponse(BaseModel):
    id: Optional[int] = Field(None, description="项目主键")
    code: Optional[str] = Field(None, description="项目代号")
    name: Optional[str] = Field(None, description="项目名称")
    case_id: Optional[int] = Field(None, description="关联案情ID")
    presale_entry_time: Optional[datetime] = Field(None, description="售前进入时间")
    presale_pm: Optional[str] = Field(None, description="售前PM")
    presale_person: Optional[str] = Field(None, description="售前")
    customer_code: Optional[str] = Field(None, description="客户编号")
    customer_name: Optional[str] = Field(None, description="客户名称")
    salesperson: Optional[str] = Field(None, description="")
    department: Optional[str] = Field(None, description="事业部")
    opportunity_category: Optional[str] = Field(None, description="商机类别")
    products: Optional[str] = Field(None, description="产品线")
    agile_product_line: Optional[str] = Field(None, description="敏态产品")
    project_phase: Optional[str] = Field(None, description="项目阶段")
    project_progress: Optional[str] = Field(None, description="项目进度")
    factory_progress: Optional[str] = Field(None, description="工厂建设状况")
    factory_planning: Optional[str] = Field(None, description="工厂规划需求")
    competitors: Optional[str] = Field(None, description="竞争对手")
    customer_budget: Optional[Decimal] = Field(None, description="客户预算")
    last_update_time: Optional[datetime] = Field(None, description="最近更新时间")
    recent_notes: Optional[str] = Field(None, description="近况备注")
    expected_signing_date: Optional[date] = Field(None, description="预计签约日")
    confidence_level: Optional[str] = Field(None, description="把握度")
    high_level_description: Optional[str] = Field(None, description="高阶论述")
    quote_amount_total: Optional[Decimal] = Field(None, description="报价-总金额")
    signing_status_date: Optional[datetime] = Field(None, description="签约/战败/暂停日")
    contract_amount_total: Optional[Decimal] = Field(None, description="签约-总金额")
    create_time: Optional[datetime] = Field(None, description="创建时间")
    update_time: Optional[datetime] = Field(None, description="更新时间")
    case_report_score: Optional[int] = Field(None, description="案情报告总分")
    quality_level: Optional[str] = Field(None, description="质量等级")
    quality_score: Optional[int] = Field(None, description="质量分数")
    project_authenticity: Optional[str] = Field(None, description="项目真伪")
    authenticity_score: Optional[int] = Field(None, description="真伪分数")
    win_rate: Optional[str] = Field(None, description="项目胜率")
    win_rate_score: Optional[int] = Field(None, description="胜率分数")
    erp_status: Optional[str] = Field(None, description="信息化应用状况")
    mes_status: Optional[str] = Field(None, description="MES状况")
    project_scale: Optional[str] = Field(None, description="项目规模（纯数值，如人数、金额等）")
    created_by: Optional[str] = Field(None, description="创建人")
    updated_by: Optional[str] = Field(None, description="更新人")
    created_dept: Optional[str] = Field(None, description="创建人部门")
    research_date: Optional[date] = Field(None, description="调研日期")
    proposal_date: Optional[date] = Field(None, description="提案日期")
    project_approval_date: Optional[date] = Field(None, description="立项日期")
    salers_id: Optional[int] = Field(None, description="销售人员ID，关联salesperson表")
    is_sprint_project: Optional[str] = Field(None, description="冲刺项目否 Y/N")

    class Config:
        from_attributes = True